package com.deman.framework.rpc.core;

import com.deman.framework.rpc.model.MessageRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ConcurrentHashMap;


/**
 * 调用请求集合
 *
 */
public class MessageCallBackHolder {
    private static ConcurrentHashMap <String, MessageCallBack> mapCallBack = new ConcurrentHashMap <>();

    public static  MessageCallBack put(MessageRequest messageRequest) {
        MessageCallBack messageCallBack = new MessageCallBack(messageRequest);
        mapCallBack.put(messageRequest.getMessageId(), messageCallBack);
        return messageCallBack;
    }

    public static MessageCallBack get(String messageId) {
        return mapCallBack.remove(messageId);
    }
}
